import {
    HTTP
} from "../utils/http.js";

export class Order extends HTTP {

    mobile(data) {
        return this.request({
            url: 'user/mobile',
            method: 'POST',
            data
        })
    }

    getOrderDetail(id) {
        return this.request({
            url: 'goods/order',
            data: { id }
        })
    }

    getOrderCommonDetail(id) {
        return this.request({
            url: 'goods/common_order',
            data: { id }
        })
    }
    

    pay({ order_id, total, address_id, remark }) {
        return this.request({
            url: 'goods/pay',
            method: 'POST',
            data: {
                order_id,
                total,
                address_id,
                remark
            }
        })
    }

    getGoodsOrders(page = 0, status = -1) {
        return this.request({
            url: 'goods/orders',
            data: {
                page,
                status,
                version: 'new'
            }
        })
    }

    orderRefund(order_id, reason) {
        return this.request({
            url: 'goods/do_back',
            method: 'POST',
            data: {
                order_id,
                reason
            }
        })
    }

    verificationOrder(id) {
        return this.request({
            url: 'goods/common_order',
            data: { id }
        })
    }
    
    goUse({ order_id, password, shopname, use_num }) {
        return this.request({
            url: 'goods/do_use',
            method: 'POST',
            data: {
                order_id,
                password,
                shopname,
                use_num
            }
        })
    }

    goodConfirm(order_id) {
      return this.request({
        url: 'goods/confirm',
        method: 'POST',
        data: {
          order_id
        }
      })
    }

    getExpress(order_id) {
      return this.request({
        url: 'goods/express',
        data: { order_id }
      })
    }
  
}